#!/bin/bash

if [ ! -d "/usr/local/include/gtest" ]; then
    echo "---------------install googletest-------------------------"
    git clone git@github.com:google/googletest.git --depth=1

    cd googletest

    cmake -B build 
    cmake --build build


    cd build
    make
    sudo make install    # Install in /usr/local/ by default
    cd ../..
    rm -rf googletest
else 
    echo "It had installed googletest"
fi


if [ ! -d "/usr/local/include/benchmark" ]; then
    echo "---------------install google benchmark-------------------------"
    git clone git@github.com:google/benchmark.git  --depth=1
    cd benchmark

    cmake -E make_directory "build"
    cmake -E chdir "build" cmake -DBENCHMARK_ENABLE_GTEST_TESTS=OFF  -DCMAKE_BUILD_TYPE=Release ../

    sudo cmake --build "build" --config Release --target install
    cd ..
    rm -rf benchmark
else 
    echo "It had installed benchmark"
fi

echo "---------------install gflags-------------------------"
sudo apt install -y libgflags-dev
